<template>
  <div>
    <nav>
      <router-link to="/" :class="{ active: $route.path == '/' }">
        <img
          src="https://m-mall.gxptkc.com/static/tab-bar/home-selected.png"
          alt=""
          v-if="$route.path == '/'"
        />
        <img
          src="https://m-mall.gxptkc.com/static/tab-bar/home.png"
          alt=""
          v-else
        />
        <span>首页</span>
      </router-link>
      <router-link to="/cart" :class="{ active: $route.path == '/cart' }">
        <img
          src="https://m-mall.gxptkc.com/static/tab-bar/cart-selected.png"
          alt=""
          v-if="$route.path == '/cart'"
        />
        <img
          src="https://m-mall.gxptkc.com/static/tab-bar/cart.png"
          alt=""
          v-else
        />

        <span>购物车</span>
      </router-link>
      <router-link to="/own" :class="{ active: $route.path == '/own' }">
        <img
          src="https://m-mall.gxptkc.com/static/tab-bar/mine-selected.png"
          alt=""
          v-if="$route.path == '/own'"
        />
        <img
          src="https://m-mall.gxptkc.com/static/tab-bar/mine.png"
          alt=""
          v-else
        />

        <span>我的</span>
      </router-link>
    </nav>

    <router-view v-slot="{ Component }">
      <keep-alive>
        <component :is="Component" />
      </keep-alive>
    </router-view>
  </div>
</template>

<script>
export default {};
</script>

<style lang="scss" scoped>
nav {
  padding: 0;
  height: 55px;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background-color: #fff;

  position: fixed;
  bottom: 0;
  left: 0;
  color: #fff;
  z-index: 999;

  a {
    display: flex;
    flex-direction: column;
    align-items: center;
    img {
      width: 24px;
    }
  }
  .active {
    color: rgb(247, 26, 3);
  }
}
</style>